<div class="navbar">
	<div class="navbar-inner">
		<a class="brand" href="#">Node CMS <?php echo Config::get('version'); ?></a>
		<ul class="nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo Navigation::getControllerTitle(Router::getController()); ?>&nbsp;<b class="caret"></b></a>
				<ul class="dropdown-menu">
					<?php
					$controllers = Navigation::getData();
					$actions = array();
					$curr_url = '';
					foreach ($controllers as $controller_id => $controller) {
						if (!User::checkAccess(User::getId(), $controller_id)) {
							continue;
						}
						
						$url = BASE_URL . $controller_id . '/';
						$class_name = '';
						if (Router::getController() == $controller_id) {
							$class_name = 'active';
							if (isset($controller['actions'])) {
								$actions = $controller['actions'];
							}
							$curr_url = $url;
						} else if (isset($controller['on_access']) && $controller['on_access']) {
							continue;
						}
						
						if (!isset($controller['title'])) {
							$controller['title'] = $controller_id;
						} ?>
						<li class="<?php echo $class_name; ?>"><a href="<?php echo $url; ?>" class="<?php echo $class_name; ?>"><?php echo __($controller['title']); ?></a></li>
					<?php } ?>
				</ul>
			</li>
		</ul>
		<ul class="nav pull-right">
		<?php
		if (count(Config::get('list', 'i18n')) > 1) { ?>
			<li style="padding:0px 2px;">
				<div class="btn-group">
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						<img src="<?php echo PUBLIC_URL; ?>images/flag/<?php echo Router::getLanguage(); ?>.png" style="width:16px; height:11px; float:left; margin:5px 5px 0px 0px;" />
						<?php echo __('Site'); ?>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<?php foreach (Config::get('list', 'i18n') as $lang) {
							$class_name = '';
							if ($lang == Router::getLanguage()) {
								$class_name = ' active';
							} ?>
							<li class="<?php echo $class_name; ?>"><a href="#" onclick="Core.Site.changeLanguage('<?php echo $lang; ?>');">
								<img src="<?php echo PUBLIC_URL; ?>images/flag/<?php echo $lang; ?>.png" style="width:16px; height:11px; float:right; margin:5px 0px 0px 0px;" />
								<?php echo __('language_' . $lang); ?>
							</a></li>
						<?php } ?>
					</ul>
				</div>
			</li>
		<?php }

		if (count(Config::get('schema_list', 'i18n')) > 1) { ?>
			<li style="padding:0px 2px;">
				<div class="btn-group">
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						<img src="<?php echo PUBLIC_URL; ?>images/flag/<?php echo Config::get('schema_current', 'i18n'); ?>.png" style="width:16px; height:11px; float:left; margin:5px 5px 0px 0px;" />
						<?php echo __('Schema'); ?>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<?php foreach (Config::get('schema_list', 'i18n') as $lang) {
							$class_name = '';
							if ($lang == Config::get('schema_current', 'i18n')) {
								$class_name = ' active';
							} ?>
							<li class="<?php echo $class_name; ?>"><a href="#" onclick="Core.Schema.changeLanguage('<?php echo $lang; ?>');">
								<img src="<?php echo PUBLIC_URL; ?>images/flag/<?php echo $lang; ?>.png" style="width:16px; height:11px; float:right; margin:5px 0px 0px 0px;" />
								<?php echo __('language_' . $lang); ?>
							</a></li>
						<?php } ?>
					</ul>
				</div>
			</li>
		<?php } ?>
			<li style="padding:0px 2px;">
				<div class="btn-group">
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						<?php echo User::getName(); ?>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="<?php echo BASE_URL; ?>user/logout"><?php echo __('Logout'); ?></a></li>
					</ul>
				</div>
			</li>
		</ul>
	</div>
</div>


<div>
	<ul class="nav nav-tabs">
	<?php
	if (!empty($actions)) {
		foreach ($actions as $action_id => $action) {
			if (!User::checkAccess(User::getId(), Router::getController(), $action_id)) {
				continue;
			}
			$url = $curr_url . $action_id . '/';
			if (isset($action['uri'])) {
				$url .= $action['uri'] . '/';
			}

			$class_name = '';
			if (Router::getAction() == $action_id) {
				$class_name = 'active';
				if (isset($action['uri_segment'])) {
					$url .= Uri::getSegment(intval($action['uri_segment']));
				}
			} else if (isset($action['on_access']) && $action['on_access']) {
				continue;
			}
			if (!isset($action['title'])) {
				$action['title'] = $action_id;
			} ?>
			<li class="<?php echo $class_name; ?>">
				<a href="<?php echo $url; ?>"><?php echo __($action['title']); ?></a>
			</li>
		<?php }
	} ?>
	</ul>
</div>

<div id="file_browser" class="modal hide fade" style="width:960px; margin:-350px 0 0 -480px;">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		<h3>File Browser</h3>
	</div>
	<div class="modal-body" style="width:930px; max-height:700px; height:600px;">
		<iframe src="about:blank" id="file_browser_content" width="100%" height="100%" frameborder="0"></iframe>
	</div>
</div>